import { uniqueId } from "lodash";
import { objs, work } from "./modules/works";

/**
 * @description 给菜单数据补充上 path 字段
 * @description https://github.com/d2-projects/d2-admin/issues/209
 * @param {Array} menu 原始的菜单数据
 */
function supplementPath(menu) {
  return menu.map(e => ({
    ...e,
    path: e.path || uniqueId("d2-menu-empty-"),
    ...(e.children
      ? {
          children: supplementPath(e.children)
        }
      : {})
  }));
}
const Arrays = [{ path: "/index", title: "首页", icon: "home" }];
if (JSON.stringify(objs) != "{}") {
  for (var i in objs) {
    Arrays.push(objs[i]);
  }
}
export const menuHeader = supplementPath(Arrays);
export const menuAside = supplementPath(work);
